package org.nf.trading.controller.app.product;


import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nf.trading.controller.BaseController;
import org.nf.trading.dao.ProductTypeDetailMapper;
import org.nf.trading.exception.app.product.ProductDataException;
import org.nf.trading.vo.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/api/productTypeDetail")
public class ProductTypeDetailController extends BaseController {
    private final ProductTypeDetailMapper productTypeDetailMapper;

    @GetMapping("{productTypeId}")
    public ResultVO getAllByProductTypeDetailsByTypeId(@PathVariable("productTypeId") Integer productTypeId){
        if (productTypeId == null){
            throw new ProductDataException(500,"参数productTypeId为NULL");
        }
        return success(productTypeDetailMapper.getAllByProductTypeDetailsByTypeId(productTypeId));
    }
}
